<?php
  require_once 'lib/HTML/Util.php';
  require_once 'lib/HTML/LinkLoader.php';
  require_once 'lib/HTML/FormElements.php';
  require_once 'controllers/Artist.php';
 
  if(is_numeric($_GET['aid']) && $_GET['aid'] > 0)
  {
  	    
  $artist = new Artist(array(id=>$_GET['aid']));
  try{ $artist->getDetails(); }
  catch(MTException $e){ die($e->getMessage()); }

  if($artist->result() == null)
      header("Location: ?view=artist&action=listen&aid={$_GET['aid']}&error=not+found");
  
  $artist->getPicture();
  
  $smarty->assign_by_ref("artist_info",$artist->result());
  $smarty->assign('time_added', $artist->getTime());
  $smarty->assign("title", "Artist: {$artist->result()->name}");
  
  try
  {  
    $smarty->assign_by_ref("artist_releases",$artist->getReleases()->result());
  }
  catch(MTException $e){ die($e->getMessage()); }
  
  }else{
      header("Location: index.php");
  }
    
  $ll = new LinkLoader();
  $ll->loadCSS(array('listen.css','tabs.css','form.css'));
  
  $ll->loadJs(array('Ajax.js','WebServices/WebService.js',
                    'WebServices/MusicBrainz.js','Components/Track.js',
                    'Components/Article.js','MusicTalk.js','Tabs.js','WebServices/YouTubeVids.js','lib/swfobject.js','Player.js'));
  $ll->loadJs('js.js','views/artist/listen/');
  
  $smarty->assign_by_ref("ll", $ll);
  $smarty->assign_by_ref("html",new Util());
  //$smarty->assign_by_ref("fe",new FormElements());
     
  $smarty->display("head.tpl");
  $smarty->display("nav.tpl");
  // main content
  $smarty->display("../artist/listen/view.tpl");
  
  $smarty->display("footer.tpl");
?>

    
    
